package com.ruoyi.web.controller.laiqianba.account;

import com.ruoyi.account.service.IAccountMerchantInfoHisService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.db.domain.AccountMerchantInfoHis;
import com.ruoyi.web.wrapper.AccountChannelInfoHisWrapper;
import com.ruoyi.web.wrapper.AccountMerchantInfoHisWrapper;
import com.ruoyi.web.wrapper.AccountOwnerHisWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * 商户账户流水Controller
 * 
 * @author ruoyi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/account/merchantInfoHis")
public class AccountMerchantInfoHisController extends BaseController
{
    @Autowired
    private IAccountMerchantInfoHisService accountMerchantInfoHisService;

    /**
     * 查询商户账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountMerchantInfoHis accountMerchantInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountMerchantInfoHisService.selectAccountMerchantInfoHisMapList1(accountMerchantInfoHis);
        list = new AccountMerchantInfoHisWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 查询商务账单流水
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:owner')")
    @GetMapping("/owner/list")
    public TableDataInfo owner(AccountMerchantInfoHis accountMerchantInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountMerchantInfoHisService.selectAccountOwnerMapList(accountMerchantInfoHis);
        list = new AccountOwnerHisWrapper(list).wrap();
        return getDataTable(list);
    }
    /**
     * 查询商务账单流水
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:owner')")
    @GetMapping("/His/list")
    public TableDataInfo his(AccountMerchantInfoHis accountMerchantInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountMerchantInfoHisService.selectAccountHisMapList(accountMerchantInfoHis);
        list = new AccountChannelInfoHisWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:export')")
    @Log(title = "商户账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountMerchantInfoHis accountMerchantInfoHis)
    {
        List<AccountMerchantInfoHis> list = accountMerchantInfoHisService.selectAccountMerchantInfoHisList(accountMerchantInfoHis);
        ExcelUtil<AccountMerchantInfoHis> util = new ExcelUtil<AccountMerchantInfoHis>(AccountMerchantInfoHis.class);
        util.exportExcel(response, list, "商户账户流水数据");
    }

    /**
     * 获取商户账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountMerchantInfoHisService.selectAccountMerchantInfoHisById(id));
    }

    /**
     * 新增商户账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:add')")
    @Log(title = "商户账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountMerchantInfoHis accountMerchantInfoHis)
    {
        return toAjax(accountMerchantInfoHisService.insertAccountMerchantInfoHis(accountMerchantInfoHis));
    }

    /**
     * 修改商户账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:edit')")
    @Log(title = "商户账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountMerchantInfoHis accountMerchantInfoHis)
    {
        return toAjax(accountMerchantInfoHisService.updateAccountMerchantInfoHis(accountMerchantInfoHis));
    }

    /**
     * 删除商户账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:merchantInfoHis:remove')")
    @Log(title = "商户账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountMerchantInfoHisService.deleteAccountMerchantInfoHisByIds(ids));
    }
}
